<?php
/**
 * Created by PhpStorm.
 * User: jifee8505
 * Date: 2018/1/18
 * Time: 上午11:28
 */

namespace backend\widgets;

use backend\models\match\MatchUserSearch;
use Yii;
use yii\base\Widget;
use yii\base\InvalidConfigException;

/** <?= MatchUserTable::widget(['model' => $model]) ?> */
class MatchUserTable extends Widget
{
    public $model;

    public function init()
    {
        parent::init();

        if (empty($this->model)) {
            throw new InvalidConfigException('Required `model` param isn\'t set.');
        }
    }

    public function run()
    {
        $queryParams['MatchUserSearch'] = [
            'match_id' => $this->model->id
        ];

        Yii::$app->request->get('match_id', $this->model->id);
        $searchModel = new MatchUserSearch();

        $dataProvider = $searchModel->search($queryParams);

        return $this->render('match-user-table', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }
}